package com.wxproject.demo.Service.FackCheckService;

import com.baidu.aip.face.AipFace;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author zqf
 * @date 2021/4/4 23:27
 * @description
 */
@Component
public class DBFactory {
    private static AipFace aipFace;
    private static String appId;
    private static String apiKey;
    private static String secretKey;

    @Value("${FaceApi.appId}")
    public void setAppId(String appId) {
        DBFactory.appId = appId;
    }
    @Value("${FaceApi.apiKey}")
    public void setApiKey(String apiKey) {
        DBFactory.apiKey = apiKey;
    }
    @Value("${FaceApi.secretKey}")
    public void setSecretKey(String secretKey) {
        DBFactory.secretKey = secretKey;
    }

    /**
     * 单例加载
     * @return AipFace
     */
    public static AipFace getAipFace(){
        if(aipFace==null){
            synchronized (AipFace.class) {
                if(aipFace==null){
                    aipFace = new AipFace(appId,apiKey,secretKey);
                }
            }
        }
        return aipFace;
    }
}
